Skip to content

Add a dispatch for LinearAlgebra.norm2#2302

Draft
sharanry wants to merge 1 commit intoJuliaGPU:masterfrom
sharanry:sy/strided_norm2
Draft

Add a dispatch for LinearAlgebra.norm2#2302
sharanry wants to merge 1 commit intoJuliaGPU:masterfrom
sharanry:sy/strided_norm2

Conversation

@sharanry
Copy link
Copy Markdown

norm(@view x[..], 2) was previously leading to a call of LinearAlgebra.generic_norm2 which led to a scalar indexing. This catches such cuda subarray norm2 calls earlier.

Inf-norm and p-norm with cuda subarrays still lead to the following dispatches:

LinearAlgebra.generic_normInf(x) = float(mapreduce(norm, max, x))
LinearAlgebra.generic_norm1(x) = mapreduce(float  norm, +, x)

I am not sure if there is a better way to dispatch the above.

should resolve #2280

`norm(@view x[..], 2)` was previously leading to a call of `LinearAlgebra.generic_norm2` which led to a scalar indexing. This catches such cuda subarray norm2 calls earlier.

Inf-norm and p-norm with cuda subarrays still lead to the following dispatches:
```julia
LinearAlgebra.generic_normInf(x) = float(mapreduce(norm, max, x))
LinearAlgebra.generic_norm1(x) = mapreduce(float ∘ norm, +, x)
```
I am not sure if there is a better way to dispatch the above.

should resolve JuliaGPU#2280
@maleadt
Copy link
Copy Markdown
Member

maleadt commented Mar 27, 2024

What about generalizing the LinearAlgebra.norm method above to StridedCuArray? That seems cleaner than overriding an internal method.

@maleadt maleadt added needs changes Changes are needed. labels May 24, 2024
@maleadt maleadt marked this pull request as draft May 24, 2024 13:34
@maleadt maleadt marked this pull request as draft May 24, 2024 13:34
@maleadt maleadt added cuda array Stuff about CuArray. labels May 24, 2024
@maleadt maleadt force-pushed the master branch 15 times, most recently from 5d585c4 to c850163 Compare December 20, 2024 08:18
@Azercoco
Copy link
Copy Markdown

Azercoco commented Jan 6, 2025

Hi, what's the status of this PR ? This issue is troublemsome for one of my code and I would like to know if the fix will be implemented into CUDA.jl

@maleadt
Copy link
Copy Markdown
Member

maleadt commented Jan 6, 2025

The PR fails CI, and there's an outstanding comment of mine, so it needs work I'd say. Feel free to take it up if you want.

@maleadt maleadt added the good first issue Good for newcomers label Apr 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cuda array Stuff about CuArray. good first issue Good for newcomers needs changes Changes are needed.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2-norm for views of CuArray falls back to scalar indexing

3 participants